<template>
  <!-- 这里替换为你的上传API -->
  <el-upload
    :action="actionUrl"
  list-type="picture-card"
  multiple
  :on-preview="handlePictureCardPreview"
  :on-remove="handleRemove"
  :file-list="fileList"
  :on-success="handleSuccess"
  >
  <i class="el-icon-plus"></i>
  </el-upload>
  <el-dialog :visible.sync="dialogVisible">
    <img width="100%" :src="dialogImageUrl" alt="">
  </el-dialog>
</template>

<script>
import app from "../../constants/app";
import {getToken} from "../../utils/cache";

export default {
  data() {
    return {
      actionUrl: `${app.api}/sys/oss/uploadByLocal?token=${getToken()}`,
      dialogImageUrl: '',
      dialogVisible: false,
      fileList: []
    };
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleSuccess(response, file, fileList) {
      console.log('File uploaded successfully:', response, file, fileList);
    }
  }
};
</script>
